﻿using Autofac;
using Foundation.Core;

namespace Dyao.Book.Application
{
    public class ApplicationModule : Module
    {
        protected override void Load(ContainerBuilder containerBuilder)
        {
            var assembly = GetType().Assembly;
            containerBuilder.RegisterAssemblyTypes(assembly)
                .AssignableTo<IScopedDependency>()
                .AsSelf()
                .AsImplementedInterfaces()
                .InstancePerLifetimeScope()
                .PropertiesAutowired(new InjectedAttributeSelector());

            containerBuilder.RegisterAssemblyTypes(assembly)
                .AssignableTo<ITransientDependency>()
                .AsSelf()
                .AsImplementedInterfaces()
                .InstancePerDependency()
                .PropertiesAutowired(new InjectedAttributeSelector());

            containerBuilder.RegisterAssemblyTypes(assembly)
                .AssignableTo<ISingletonDependency>()
                .AsSelf()
                .AsImplementedInterfaces()
                .SingleInstance()
                .PropertiesAutowired(new InjectedAttributeSelector());

            TaskCenterCodeManager.LoadCodes();
        }
    }
}
